*********************************************************************************
* Title: Appendix																*
* Paper: Populism and Nativism													*
* Authors: M. Pesthy, M. Mader, H. Schoen										*
*********************************************************************************


*** Section 2 ***
	* Table A1: Regressions of AfD vote on populism, nativism and controls, by region and age group
		use DATA_WKP17.dta, clear

	* Model with both pop_g and nat_g1
		eststo m1w_1: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 0 & age_cat == 1 [pw=weight] // West, young
		eststo m1w_2: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 0 & age_cat == 2 [pw=weight] // West, old
		eststo m1o_1: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 1 & age_cat == 1 [pw=weight] // East, young
		eststo m1o_2: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 1 & age_cat == 2 [pw=weight] // East, old
	
	* Table: Regressions of AfD vote on populism, nativism and controls, by region and age group
		esttab 	m1w_1 m1w_2 m1o_1 m1o_2  using "Table_A1.rtf", replace ///
				b(2) se(2) nogaps compress nobaselevels varwidth(15) ///
				modelwidth(6) nonumbers ///
				mtitles("M1: West, young" "M1: West, old" "M1: East, young" "M1: East, old" "M3: West" "M3: East") ///
				coeflabels(	iafd1 "PID AfD" ///
							female "Gender: female" ///
							2.educat "Education: middle" ///
							3.educat "Education: high" ///
							age "Age in years" ///
							w1_pint_r "Political Interest" ///
							ewl1 "Personal Economic Situation" ///
							rural2 "Rural Environment" ///
							pop_g_r "Populism" ///
							nat_g1_r "Nativism" ///
							_cons "Constant") ///
				order(pop_g nat_g1)

	* Figure A1: Average marginal effects of populism and nativism on AfD , by region and age group
		estimates restore m1w_1
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg1
		
		estimates restore m1w_2
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg2
		
		estimates restore m1o_1
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg3
		
		estimates restore m1o_2
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg4

	set scheme s1mono
	coefplot (marg1, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
			 (marg2, mcolor(black) msize(vlarge) msymbol(diamond) ciopts(lcolor(black) lwidth(thick))) ///
			 (marg3, mcolor(gs10) msize(vlarge) msymbol(circle) ciopts(lcolor(gs10) lwidth(thick))) ///
			 (marg4, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))), ///
		coeflabels(pop_g_r="Populism" nat_g1_r="Nativism", labsize (huge)) xlab(-.1 (.1) .6, labs(huge)) ///
		subtitle(,bcolor(none)) graphregion(ifcolor(white)) xline(0, lpattern(dash) lcolor(gs8)) ///
		legend(off) ///
		text(0.70 .25 "West, <50yrs", size(large) placement(e)) ///
		text(0.90 .15 "West, 50yrs+", size(large) placement(e)) ///
		text(1.10 .30 "East, <50yrs", size(large) placement(e)) ///
		text(1.30 .30 "East, 50yrs+", size(large) placement(e)) ///
		xsize(3) ysize(2) ///
		name(FigureA1, replace)
		
	graph export FigureA1.eps, replace
	graph export FigureA1.tif, replace 
	
*** Section 3 ***

	* Table A2

		use DATA_WKP17.dta, clear
			
		eststo m1w: logit wafd8 i.type2 i.female i.educat c.age c.w1_pint_r c.ewl1 i.rural2 if ost == 0 [pw=weight] 
		eststo m1o: logit wafd8 i.type2 i.female i.educat c.age c.w1_pint_r c.ewl1 i.rural2 if ost == 1 [pw=weight] 
		
		esttab 	m1w m1o using "Table_A2.rtf", replace ///
				b(2) se(2) nogaps compress nobaselevels varwidth(30) ///
				modelwidth(7) nonumbers ///
				mtitles("West" "East") ///
				coeflabels(	2.type2 "High Populism, low Nativism" ///
							3.type2 "Low Populism, high Nativism" ///
							4.type2 "High Populism, high Nativism" ///
							1.female "Female" ///
							2.educat "Education: middle" ///
							3.educat "Education: high" ///
							age "Age in years" ///
							w1_pint_r "Political Interest" ///
							ewl1 "Personal Economic Situation" ///
							rural2 "Rural Environment" ///
							_cons "Constant") 



*** Section 4 ***
	
	* Table A3
		use DATA_WKP17.dta, clear
		
		
	* Model with pop_g
		eststo m1w: quietly mlogit wahl8 pop_g_r female i.educat age w1_pint_r ewl1 rural2 if ost == 0 [pw=weight], baseoutcome(7)	
		eststo m1o: quietly mlogit wahl8 pop_g_r female i.educat age w1_pint_r ewl1 rural2 if ost == 1 [pw=weight], baseoutcome(7)	

	* Model with nat_g1
		eststo m2w: quietly mlogit wahl8 nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 0 [pw=weight], baseoutcome(7)	
		eststo m2o: quietly mlogit wahl8 nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 1 [pw=weight], baseoutcome(7)	
		
	* Model with both pop_g and nat_g1
		eststo m3w: quietly mlogit wahl8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 0 [pw=weight], baseoutcome(7)		
		eststo m3o: quietly mlogit wahl8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 rural2 if ost == 1 [pw=weight], baseoutcome(7)

	* Table
		esttab m1w m1o m2w m2o m3w m3o using "Table_A3.rtf", replace ///
				nogaps compress nobaselevels ///
				b(2) se(2) varwidth(20) modelwidth(5) ///
				nonumbers mtitles("M1: West" "M1: East" "M2: West" "M2: East""M3: West" "M3: East") /// 
				coeflabels(	female "Gender: female" ///
							2.educat "Education: middle" ///
							3.educat "Education: high" ///
							age "Age in years" ///
							w1_pint_r "Political Interest" ///
							ewl1 "Personal Economic Situation" ///
							rural2 "Rural Environment" ///
							pop_g_r "Populism" ///
							nat_g1_r "Nativism" ///
							_cons "Constant") ///
				order(pop_g_r nat_g1_r)
		
	
	* Figure A2: Average marginal effects of populism and nativism on AfD vote in East and West Germany (multinomial regression)
	
		estimates restore m1w
		margins, dydx(pop_g_r) predict(outcome(6)) post
		eststo marg1w
		
		estimates restore m1o
		margins, dydx(pop_g_r) predict(outcome(6)) post
		eststo marg1o
		
		estimates restore m2w
		margins, dydx(nat_g1_r) predict(outcome(6)) post
		eststo marg2w
		
		estimates restore m2o
		margins, dydx(nat_g1_r) predict(outcome(6)) post
		eststo marg2o
		
		estimates restore m3w
		margins, dydx(pop_g_r nat_g1_r) predict(outcome(6)) post
		eststo marg3w
		
		estimates restore m3o
		margins, dydx(pop_g_r nat_g1_r) predict(outcome(6)) post
		eststo marg3o

		set scheme s1mono
	
		coefplot (marg1w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))  mlabposition(3) mlabgap(8) mlabsize(huge))  ///
				 (marg1o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick)) mlabposition(3) mlabgap(15) mlabsize(huge) mlabcolor(gs10)) ///
				 || (marg2w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg2o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 || (marg3w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg3o,  mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 ||, byopts(cols(3)legend(off)) norecycle ///
			bylabels("Model 1" "Model 2" "Model 3") subtitle(,bcolor(none) size(huge)) ///
			legend(off) text(.81 .06 "West", size(huge) placement(e)) text(1.14 .13 "East", color(gs10) size(huge) placement(e)) ///	EDIT MARKER LABELS IN GRAPH EDITOR
			coeflabels(pop_g_r="Populism" nat_g1_r="Nativism", labsize (huge))  xlab(-.1 (.1) .6, labs(huge)) ///
			graphregion(ifcolor(white)) xline(0, lpattern(dash) lcolor(gs8)) ///
			xtitle("Average marginal effect", size(huge)) /// 
			xsize(3) ysize(1) name(FigureA2, replace)
		
		graph export FigureA2.eps, replace
		graph export FigureA2.tif, replace

	* Figure A3

		use DATA_WKP17.dta, clear

		mlogit wahl8 i.type2 i.female i.educat c.age c.w1_pint_r c.ewl1 i.rural2 if ost == 0 [pw=weight], baseoutcome(7)	
		margins, at(type2 = (1 2 3 4)) predict(outcome(6)) post 
		eststo marg1

		mlogit wahl8 i.type2 i.female i.educat c.age c.w1_pint_r c.ewl1 i.rural2 if ost == 1 [pw=weight], baseoutcome(7)	
		margins, at(type2 = (1 2 3 4)) predict(outcome(6)) post 
		eststo marg2
			
		coefplot (marg1, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
					(marg2, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) , ///
			scheme(s1mono) ///
			coeflabels(1._at="Group 1: low populism, low nativism" 2._at = "Group 2: high populism, low nativism" 3._at = "Group 3: low populism, high nativism" 4._at = "Group 4: high populism, high nativism", labsize (vlarge)) ///
			xtitle("Probability of AfD vote", size(vlarge)) xlab(0 (.1) .4, labs(vlarge)) ///
			legend(off) text(.8 .08 "West", size(large) placement(e)) text(1.125 .13 "East", color(gs10) size(large) placement(e)) ///
			subtitle(,bcolor(none)) graphregion(ifcolor(white)) ///
			xline(.13, lpattern(dash) lcolor(gs12)) text(4.1 .125  "Prop.", size(large) color(gs12)  placement(w)) text(4.3 .125  "West", size(large) color(gs12) placement(w)) ///
			xline(.20, lpattern(dash) lcolor(gs12)) text(4.1 .195  "Prop.", size(large) color(gs12)  placement(w)) text(4.3 .195  "East", size(large) color(gs12) placement(w)) ///
			xsize(2) ysize(1) name(FigureA3, replace)

	graph export FigureA3.eps, replace
	graph export FigureA3.tif, replace

*** Section 5 ***
	
	* Table A4

		use DATA_WKP17.dta, clear
		estimates clear
		
	* Model with pop_g
		eststo m1w: quietly logit wafd8 pop_g_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 0 [pw=weight]
		eststo m1o: quietly logit wafd8 pop_g_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 1 [pw=weight]
		
	* Model with nat_g1
		eststo m2w: quietly logit wafd8 nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 0 [pw=weight]
		eststo m2o: quietly logit wafd8 nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 1 [pw=weight]	
		
	* Model with both pop_g and nat_g1
		eststo m3w: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 0 [pw=weight]	
		eststo m3o: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 w1_pi if ost == 1 [pw=weight]
		
	* Table
		esttab m1w m1o m2w m2o m3w m3o using "Table_A4.rtf", replace ///
				nogaps compress nobaselevels ///
				b(2) se(2) varwidth(20) modelwidth(5) ///
				nonumbers mtitles("M1: West" "M1: East" "M2: West" "M2: East""M3: West" "M3: East") /// 
				coeflabels(	female "Gender: female" ///
							2.educat "Education: middle" ///
							3.educat "Education: high" ///
							age "Age in years" ///
							w1_pint_r "Political Interest" ///
							ewl1 "Personal Economic Situation" ///
							rural2 "Rural Environment" ///
							pop_g_r "Populism" ///
							nat_g1_r "Nativism" ///
							1.w1_pi "PID CDU/CSU" ///
							2.w1_pi "PID SPD" ///
							3.w1_pi "PID Green" ///
							4.w1_pi "PID Left" ///
							5.w1_pi "PID FDP" ///
							6.w1_pi "PID AfD" ///
							7.w1_pi "PID Other" ///
							_cons "Constant") ///
				order(pop_g_r nat_g1_r)	
		
		
	* Figure A4: Average marginal effects of populism and nativism on AfD vote in East and West Germany (pi controlled)
		estimates restore m1w
		margins, dydx(pop_g_r) post
		eststo marg1w
		
		estimates restore m1o
		margins, dydx(pop_g_r) post
		eststo marg1o
		
		estimates restore m2w
		margins, dydx(nat_g1_r) post
		eststo marg2w
		
		estimates restore m2o
		margins, dydx(nat_g1_r) post
		eststo marg2o
		
		estimates restore m3w
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg3w
		
		estimates restore m3o
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg3o

		set scheme s1mono
		coefplot (marg1w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick)) )  ///
				 (marg1o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick)) ) ///
				 || (marg2w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg2o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 || (marg3w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg3o,  mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 ||, byopts(cols(3)legend(off)) norecycle ///
			bylabels("Model 1" "Model 2" "Model 3") subtitle(,bcolor(none) size(huge)) ///
			coeflabels(pop_g_r="Populism" nat_g1_r="Nativism", labsize (huge))  xlab(-.1 (.1) .3, labs(huge)) ///
			legend(off) text(.81 .06 "West", size(huge) placement(e)) text(1.14 .13 "East", color(gs10) size(huge) placement(e)) ///	EDIT MARKER LABELS IN GRAPH EDITOR
			graphregion(ifcolor(white)) xline(0, lpattern(dash) lcolor(gs8)) ///
			xtitle("Average marginal effect", size(huge)) /// 
			xsize(3) ysize(1) name(FigureA4, replace)

	graph export FigureA4.eps, replace
	graph export FigureA4.tif, replace

	* Figure A5: Average marginal effects of populism and nativism subdimensions on AfD vote in East and West Germany (pi controlled)	
		use DATA_WKP17.dta, clear
		
		logit wafd8 i.type2 i.female i.educat c.age w1_pint_r c.ewl1 i.w1_pi i.rural2 if ost == 0 [pw=weight]
		margins, at(type2 = (1 2 3 4)) post 
		eststo marg1

		logit wafd8 i.type2 i.female i.educat c.age w1_pint_r c.ewl1 i.w1_pi i.rural2 if ost == 1 [pw=weight]	
		margins, at(type2 = (1 2 3 4)) post 
		eststo marg2
				

		set scheme s1mono
		coefplot (marg1, mcolor(black) msize(large) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg2, mcolor(gs10) msize(large) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) , ///
			scheme(s1mono) ///
			coeflabels(1._at="Group 1: low populism, low nativism" 2._at = "Group 2: high populism, low nativism" 3._at = "Group 3: low populism, high nativism" 4._at = "Group 4: high populism, high nativism", labsize (vlarge)) ///
			xtitle("Probability of AfD vote", size(vlarge)) xlab(0 (.1) .4, labs(vlarge)) ///
			legend(off) text(.8 .06 "West", size(large) placement(w)) text(1.125 .085 "East", color(gs10) size(large) placement(w)) ///
			subtitle(,bcolor(none)) graphregion(ifcolor(white)) ///
			xline(.13, lpattern(dash) lcolor(gs12)) text(4.1 .125  "Prop.", size(large) color(gs12)  placement(w)) text(4.3 .125  "West", size(large) color(gs12) placement(w)) ///
			xline(.20, lpattern(dash) lcolor(gs12)) text(4.1 .195  "Prop.", size(large) color(gs12)  placement(w)) text(4.3 .195  "East", size(large) color(gs12) placement(w)) ///
			xsize(2) ysize(1) name(FigureA5, replace)
		
	graph export FigureA5.eps, replace
	graph export FigureA5.tif, replace

***** additional control variables as suggested by Rev 2 *****

* Table A4

		use DATA_WKP17.dta, clear
		estimates clear
		
	* Model with pop_g
		eststo m1w: quietly logit wafd8 pop_g_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 0 [pw=weight]
		eststo m1o: quietly logit wafd8 pop_g_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 1 [pw=weight]
		
	* Model with nat_g1
		eststo m2w: quietly logit wafd8 nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 0 [pw=weight]
		eststo m2o: quietly logit wafd8 nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 1 [pw=weight]	
		
	* Model with both pop_g and nat_g1
		eststo m3w: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 0 [pw=weight]	
		eststo m3o: quietly logit wafd8 pop_g_r nat_g1_r female i.educat age w1_pint_r ewl1 i.rural2 ib(8).w1_pi merkel1 exteff1 dem_zuf1 if ost == 1 [pw=weight]
		
	* Table
		esttab m1w m1o m2w m2o m3w m3o using "Table_A4_c.rtf", replace ///
				nogaps compress nobaselevels ///
				b(2) se(2) varwidth(20) modelwidth(5) ///
				nonumbers mtitles("M1: West" "M1: East" "M2: West" "M2: East""M3: West" "M3: East") /// 
				coeflabels(	female "Gender: female" ///
							2.educat "Education: middle" ///
							3.educat "Education: high" ///
							age "Age in years" ///
							w1_pint_r "Political Interest" ///
							ewl1 "Personal Economic Situation" ///
							1.rural2 "Rural Environment" ///
							pop_g_r "Populism" ///
							nat_g1_r "Nativism" ///
							1.w1_pi "PID CDU/CSU" ///
							2.w1_pi "PID SPD" ///
							3.w1_pi "PID Green" ///
							4.w1_pi "PID Left" ///
							5.w1_pi "PID FDP" ///
							6.w1_pi "PID AfD" ///
							7.w1_pi "PID Other" ///
							merkel1 "Merkel Eval" ///
							exteff1 "External Efficacy" ///
							dem_zuf1 "Satisfaction Democracy" ///
							_cons "Constant") ///
				order(pop_g_r nat_g1_r)	
		
		
	* Figure A4: Average marginal effects of populism and nativism on AfD vote in East and West Germany (pi controlled)
		estimates restore m1w
		margins, dydx(pop_g_r) post
		eststo marg1w
		
		estimates restore m1o
		margins, dydx(pop_g_r) post
		eststo marg1o
		
		estimates restore m2w
		margins, dydx(nat_g1_r) post
		eststo marg2w
		
		estimates restore m2o
		margins, dydx(nat_g1_r) post
		eststo marg2o
		
		estimates restore m3w
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg3w
		
		estimates restore m3o
		margins, dydx(pop_g_r nat_g1_r) post
		eststo marg3o

		set scheme s1mono
		coefplot (marg1w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick)))  ///
				 (marg1o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 || (marg2w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg2o, mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 || (marg3w, mcolor(black) msize(vlarge) msymbol(circle) ciopts(lcolor(black) lwidth(thick))) ///
				 (marg3o,  mcolor(gs10) msize(vlarge) msymbol(diamond) ciopts(lcolor(gs10) lwidth(thick))) ///
				 ||, byopts(cols(3)legend(off)) norecycle ///
			bylabels("Model 1" "Model 2" "Model 3") subtitle(,bcolor(none) size(huge)) ///
			coeflabels(pop_g_r="Populism" nat_g1_r="Nativism", labsize (huge))  xlab(-.1 (.1) .3, labs(huge)) ///
			graphregion(ifcolor(white)) xline(0, lpattern(dash) lcolor(gs8)) ///
			xtitle("Average marginal effect", size(huge)) /// 
			legend(off) text(.81 .125 "West", size(huge) placement(e)) text(1.14 .21 "East", color(gs10) size(huge) placement(e)) ///	EDIT MARKER LABELS IN GRAPH EDITOR
			xsize(3) ysize(1) name(FigureA4_c, replace)

	graph export FigureA4_c.eps, replace
	graph export FigureA4_c.tif, replace
